/**
 * 初始化诊疗内容提示详情对话框
 */
var SdsQcentityTipsInfoDlg = {
    validateFields: {
    	entityId: {
            validators: {
                notEmpty: {
                    message: '质控病种不能为空'
                }
            }
        },
    	tipsTimDr: {
            validators: {
                notEmpty: {
                    message: '提示时机不能为空'
                }
            }
        },
    	tipsDays: {
            validators: {
                notEmpty: {
                    message: '提示天数不能为空'
                }
            }
        },
    	tipsRate: {
            validators: {
                notEmpty: {
                    message: '提示频率不能为空'
                }
            }
        },
    	linkExp: {
            validators: {
                notEmpty: {
                    message: '关联函数不能为空'
                }
            }
        },
    	expParam: {
            validators: {
                notEmpty: {
                    message: '函数入参不能为空'
                }
            }
        },
    	tipsContent: {
            validators: {
                notEmpty: {
                    message: '提示内容不能为空'
                }
            }
        },
    	handStop: {
            validators: {
                notEmpty: {
                    message: '可手动结束不能为空'
                }
            }
        },
    }
};


/**
 * 关闭此对话框
 */
SdsQcentityTipsInfoDlg.close = function() {
    parent.layer.close(parent.layer.getFrameIndex(window.name)); //先得到当前iframe层的索引,再执行关闭   
}

/**
 * 验证数据是否为空
 */
SdsQcentityTipsInfoDlg.validate = function () {
    $('#sdsQcentityTipsInfoForm').data("bootstrapValidator").resetForm();
    $('#sdsQcentityTipsInfoForm').bootstrapValidator('validate');
    return $("#sdsQcentityTipsInfoForm").data('bootstrapValidator').isValid();
}

/**
 * 提交新增
 */
SdsQcentityTipsInfoDlg.addSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('sdsQcentityTipsInfoForm',Sys.backendPath + "/sds/sdsqcentitytips/add",function(res) {
        Sys.success(res.message);
    	window.parent.SdsQcentityTips.table.refresh();
        SdsQcentityTipsInfoDlg.close();
    });
}

/**
 * 提交修改
 */
SdsQcentityTipsInfoDlg.editSubmit = function() {

    if (!this.validate()) {
        return;
    }
    //提交信息
    Sys.ajaxForm('sdsQcentityTipsInfoForm',Sys.backendPath + "/sds/sdsqcentitytips/update",function(res) {
        Sys.success(res.message);
    	window.parent.SdsQcentityTips.table.refresh();
        SdsQcentityTipsInfoDlg.close();
    });
}

$(function() {
	Sys.initValidator("sdsQcentityTipsInfoForm", SdsQcentityTipsInfoDlg.validateFields);
});
